package com.icss.company.service.impl;

import com.icss.company.dao.EmpMapper;
import com.icss.company.pojo.Emp;
import com.icss.company.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    @Transactional(readOnly = true)
    public List<Map<String, Object>> list(String ename) {
        return empMapper.list(ename);
    }

    @Override
    @Transactional
    public boolean del(Integer empno) {
        return empMapper.del(empno) > 0;
    }

    @Override
    @Transactional
    public boolean add(Emp emp) {
        try {
            return empMapper.add(emp) > 0;
        } catch (Exception e) {
            return false;
        }
    }

    @Override
    @Transactional(readOnly = true)
    public Map<String, Object> get(Integer empno) {
        return empMapper.get(empno);
    }

    @Override
    @Transactional
    public boolean update(Emp emp) {
        try {
            return empMapper.update(emp) > 0;
        } catch (Exception e) {
            return false;
        }
    }
    @Override
    public List<Map<String,Object>> search(Map<String,Object> params) {
        return empMapper.search(params);
    }

}
